program example
use polymorphic_complextaylor
implicit none 
integer no,nv,k
complex(dp) c,cc
type(complextaylor) f,g
 

no=6; nv= 4;    ! no: the order of the polynomial    nv: the number of variables   
call init(no,nv)  ! initializes taylor series without maps

call alloc(f,g)      ! must be constructed after init

c=cmplx(5.d0,-1.4d0,kind=dp)
cc=cmplx(6.d0,1.6d0,kind=dp)  

k=1
f=(c.mono.'023')+((c-1).mono.'011')+(cc.mono.'004')+3.d0
g=f<=k     ! Shifts exponents downwards by k
  !  Creates (5.d0 x_1^2 x_2^3 - 1.4d0 i* x_1^2 x_2^3) + (4.d0 x_1 x_2 - 1.4d0 i* x_1 x_2)
  !                     + (6.d0 x_2^4 + 1.6d0 i* x_2^4) + 3.d0
  !       <---------------------- comment added
call print(f,6)
call print(g,6)


k=2
f=(c.mono.'0032')+((c-1).mono.'0011')+(cc.mono.'0040')+3.d0
g=f<=k     ! Shifts exponents downwards by k
  !  Creates (5.d0 x_1^3 x_2^2 -1.4d0 i* x_1^3 x_2^2) + (4.d0 x_1 x_2 -1.4d0 x_1 x_2)
  !                    + (6.d0 x_1^4 +1.6d0 x_1^4) + 3.d0
  !        <---------------------- comment added
call print(f,6)
call print(g,6)

!  This is not permissible
! FPP will return the exception 
! "trouble in dashift"
! because the fist monomial
! (c.mono.'0132') cannot be shifted by 2 notches

!k=2
!f=(c.mono.'0132')+(c.mono.'0011')+(cc.mono.'0040')+3.d0
!g=f<=k     ! Shifts exponents downwards by k

call kill(f,g)      ! must be destroyed
end program example